import java.security.MessageDigest;

/**
 * @author：刘东
 * @created: 2013-4-24 上午09:36:38 
 * @version：$Id$ 
 * @since:1.0
 * @copyright 
 *
 */

public class MD5 {

	/**
	 * @param args
	 */
	private String Md5(String plainText) {
		String pwd="";
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			md.update(plainText.getBytes());
			byte b[] = md.digest();

			int i;

			StringBuffer buf = new StringBuffer("");
			for (int offset = 0; offset < b.length; offset++) {
				i = b[offset];
				if (i < 0)
					i += 256;
				if (i < 16)
					buf.append("0");
				buf.append(Integer.toHexString(i));
			}
			pwd=buf.toString();
		} catch (Exception e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		}
		return pwd;
	}

	public static void main(String[] args) {
		MD5 md5=new MD5();
		String pwd=md5.Md5("1");
		System.out.println(pwd);
	}

}
